from dataclasses import dataclass
from typing import Self  # type: ignore

from src.application.proxy.enums import AuthorizationType, ProxyStatus, ReloadType
from src.domain.common.entities import Entity


@dataclass
class ProxyEntity(Entity):
    id: int
    login: str
    password: str
    port_https: int
    reload_link: str
    server_id: int
    authorization_type: AuthorizationType = AuthorizationType.by_password
    status: ProxyStatus = ProxyStatus.available
    reload_type: ReloadType | None = None
    reload_period: int = 0

    def change_authorization_type(self, authorization_type: AuthorizationType):
        """Изменяем тип авторизации у прокси"""
        self.authorization_type = authorization_type

    def change_reload_type(self, reload_type: ReloadType, reload_period: int):
        """Изменяем тип и период ротации у прокси"""
        self.reload_type = reload_type
        self.reload_period = reload_period
